<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>墙面新增</title>
</head>

<body>
	<div class="contentt">
	<form class="cmxform" id="CheckReceiveWallAddForm" method="post" action="customer/walls/add">
		<input type="hidden" id="CheckReceiveWallAdd_articleId" >
		<div class="top" style="margin-bottom: 15px">
			<div
				style="border-bottom: 1px solid gray;height: 35px;margin-bottom: 15px">
				<span class="style_btn" style="width:100px;">墙面</span>
			</div>
			<div>
				<span class="style_btn" style="width:100px;">方位</span>&nbsp;&nbsp; 
				<select class="js-example-tags" name="direction" >
					<!-- 后期option内容后台查询
					<option value="东" selected>东</option>
					<option value="西">西</option>
					<option value="南">南</option>
					<option value="北">北</option>
					 -->
				</select>
			</div>
		</div>
		<div class="main">
			<div style="width: 100%;" class="main-top">
				<table width="100%">
					<tr>
						<td class="leftt" colspan="2"><span class="style_btn" style="width:100px;">门</span></td>
						<td colspan="2"></td>
					</tr>
					<tr>
						<td class="leftt">门</td>
						<td width="360"><input type="text" name="door">
							<!--四壁_门    上传按钮 -->
	    					<div id='filePicker_m' style="display: none">上传</div>
						</td>
						<td class="leftt">门套</td>
						<td width="360"><input type="text" name="doorCase">
							<!--四壁_门套  上传按钮 -->
	    					<div id='filePicker_mt' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td colspan="2" width="50%">
							<!-- 附件上传 四壁_门。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_m' ></div>
						</td>
						<td  colspan="2"  width="50%">
							<!-- 附件上传 四壁_门套。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_mt'></div>
						</td>
					</tr>
					<tr>
						<td class="leftt"><span class="style_btn" style="width:100px;">窗</span></td>
						<td></td>
					</tr>
					<tr>
						<td class="leftt">窗</td>
						<td><input type="text" name="window">
							<!--四壁_窗  上传按钮 -->
	    					<div id='filePicker_c' style="display: none">上传</div>
						</td>
						<td class="leftt">窗套</td>
						<td><input type="text" name="windowCase">
							<!--四壁_窗套  上传按钮 -->
	    					<div id='filePicker_ct' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<!-- 附件上传 四壁_窗。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_c'></div>
							
						</td>
						<td colspan="2">
							<!-- 附件上传 四壁_窗套。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_ct'></div>
    					</td>
					</tr>
					<tr>
						<td class="leftt">护栏</td>
						<td><input type="text" name="guardBar">
							<!-- 上传按钮 -->
	    					<div id='filePicker_hl' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<!-- 附件上传 四壁_护栏。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_hl'></div>
    					</td>
    					<td colspan="2"></td>
					</tr>
					<tr>
						<td class="leftt chufangHide weishengjianHide yangtaiHide pingtaiHide chuwujianHide"><span class="style_btn"
							style="width:100px;">电源控制</span></td>
						<td class="chufangHide weishengjianHide yangtaiHide pingtaiHide chuwujianHide" ><input type="text" name="powerCtrl">
							<!--电源控制  上传按钮 -->
	    					<div id='filePicker_dykz' style="display: none">上传</div>
						</td>
						<td class="leftt"><span class="style_btn"
							style="width:100px;">电源插座</span></td>
						<td><input type="text" name="powerSocket">
							<!--电源插座  上传按钮 -->
	    					<div id='filePicker_dycz' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<!-- 附件上传 四壁_电源控制。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_dykz'></div>
    					</td>
						<td colspan="2">
							<!-- 附件上传 四壁_电源插座。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_dycz'></div>
    					</td>
					</tr>
					<tr class="chufangHide weishengjianHide yangtaiHide pingtaiHide chuwujianHide">
						<td class="leftt"><span class="style_btn"
							style="width:100px;">网络接口</span></td>
						<td ><input type="text" name="networkSocket">
							<!-- 四壁_网络接口  上传按钮 -->
	    					<div id='filePicker_wljk' style="display: none">上传</div>
						</td>
						<td class="leftt"><span class="style_btn"
							style="width:100px;">电话接口</span></td>
						<td><input type="text" name="phoneSocket">
							<!-- 四壁_电话接口 上传按钮 -->
	    					<div id='filePicker_dhjk' style="display: none">上传</div>
						</td>
					</tr>
					<tr class="pingtaiHide chuwujianHide">
						<td colspan="2">
							<!-- 附件上传 四壁_网络接口。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_wljk'></div>
    					</td>
						<td colspan="2">
							<!-- 附件上传 四壁_电话接口。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_dhjk'></div>
    					</td>
					</tr>
					<tr class="pingtaiHide">
						<td class="leftt chufangHide weishengjianHide yangtaiHide chuwujianHide"><span class="style_btn"
							style="width:100px;">电视接口</span></td>
						<td class="chufangHide weishengjianHide yangtaiHide chuwujianHide"><input type="text" name="tvsocket">
							<!--四壁_电视接口  上传按钮 -->
	    					<div id='filePicker_dsjk' style="display: none">上传</div>
						</td>
						<td class="leftt"><span class="style_btn"
							style="width:100px;">暖气片组</span></td>
						<td><input type="text" name="heating">
							<!--四壁_暖气组片 上传按钮 -->
	    					<div id='filePicker_nqzp' style="display: none">上传</div>
						</td>
					</tr>
					<tr class="pingtaiHide">
						<td colspan="2">
							<!-- 附件上传 四壁_电视接口。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_dsjk'></div>
    					</td>
						<td colspan="2">
							<!-- 附件上传 四壁_暖气组片。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_nqzp'></div>
    					</td>
					</tr>
					<tr class="weishengjianHide yangtaiHide pingtaiHide">
						<td class="leftt"><span class="style_btn"
							style="width:100px;">空调孔洞</span></td>
						<td><input type="text" name="airconditionerHole">
							<!--四壁_空调孔洞  上传按钮 -->
	    					<div id='filePicker_ktkd' style="display: none">上传</div>
						</td>
						<td class="leftt"><span class="style_btn"
							style="width:100px;">空调位置</span></td>
						<td><input type="text" name="airconditionerSite">
							<!-- 四壁_空调位置  上传按钮 -->
	    					<div id='filePicker_ktwz' style="display: none">上传</div>
						</td>
					</tr>
					<tr class="pingtaiHide">
						<td colspan="2">
							<!-- 附件上传 四壁_空调孔洞。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_ktkd'></div>
							
    					</td>
						<td  colspan="2">
							<!-- 附件上传 四壁_空调位置。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_ktwz'></div>
    					</td>
					</tr>
					<tr class="qijushiHide cantingHide chuwujianHide yangtaiHide pingtaiHide">
						<td class="leftt"><span class="style_btn"
							style="width:100px;">热水器</span></td>
						<td><input type="text" name="waterHeater">
							<!--四壁_热水器  上传按钮 -->
	    					<div id='filePicker_waterHeater' style="display: none">上传</div>
						</td>
						<td class="leftt weishengjianHide"><span class="style_btn"
							style="width:100px;">油烟机</span></td>
						<td class="weishengjianHide"><input type="text" name="rangeHood">
							<!-- 四壁_油烟机  上传按钮 -->
	    					<div id='filePicker_lampblackMachine' style="display: none">上传</div>
						</td>
					</tr>
					<tr class="pingtaiHide chuwujianHide">
						<td colspan="2">
							<!-- 附件上传 四壁_热水器。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_waterHeater'></div>
							
    					</td>
						<td  colspan="2">
							<!-- 附件上传 四壁_油烟机。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_lampblackMachine'></div>
    					</td>
					</tr>
					<tr>
						<td class="leftt"><span class="style_btn"
							style="width:100px;">墙面装饰物</span></td>
						<td><input type="text" name="wallDecorate">
							<!-- 上传按钮 -->
	    					<div id='filePicker_qmzsw' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<!-- 附件上传 四壁_墙面装饰物。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_qmzsw'></div>
							
    					</td>
    					<td colspan="2"></td>
					</tr>
					<tr>
						<td><span class="style_btn" style="width:100px;">墙面装饰</span></td>
						<td></td>
					</tr>
					<tr>
						<td class="leftt">涂料</td>
						<td><input type="text" name="dope">
							<!--四壁_涂料  上传按钮 -->
	    					<div id='filePicker_tl' style="display: none">上传</div>
						</td>
						<td class="leftt">壁纸</td>
						<td><input type="text" name="wallpaper">
							<!-- 四壁_壁纸  上传按钮 -->
	    					<div id='filePicker_bz' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<!-- 附件上传 四壁_涂料。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_tl'></div>
    					</td>
						<td colspan="2">
							<!-- 附件上传 四壁_壁纸。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_bz'></div>
    					</td>
					</tr>
					<tr>
						<td class="leftt">软包</td>
						<td><input type="text" name="softRoll">
							<!-- 四壁_软包  上传按钮 -->
	    					<div id='filePicker_rb' style="display: none">上传</div>
						</td>
						<td class="leftt">木包</td>
						<td><input type="text" name="woodRoll">
							<!--四壁_木包  上传按钮 -->
	    					<div id='filePicker_mb' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<!-- 附件上传 四壁_软包。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_rb'></div>
    					</td>
						<td colspan="2">
							<!-- 附件上传 四壁_木包。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_mb'></div>
    					</td>
					</tr>
					<tr>
						<td class="leftt">玻璃</td>
						<td><input type="text" name="glass">
							<!--四壁_玻璃  上传按钮 -->
	    					<div id='filePicker_bl' style="display: none">上传</div>
						</td>
						<td class="leftt">砖材</td>
						<td><input type="text" name="wallBrick">
							<!--四壁_砖材  上传按钮 -->
	    					<div id='filePicker_brickMaterial' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<!-- 附件上传 四壁_玻璃。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_bl'></div>
							
    					</td>
    					<td colspan="2">
    						<!-- 附件上传 四壁_砖材。。。-->
							<!-- 缩略图容器 -->
	    					<div id='list_brickMaterial'></div>
    					</td>
					</tr>

				</table>
			</div>
			<!-- 修改时添加变更说明 -->
			<div style="margin:10px;display:none;" id="dw_div" >
				变更说明<textarea rows="3" name="remark" id="dwRemark" style="width:70%"></textarea><span style="color:red;">*</span>
			</div>
			<div style="width:100%;text-align:center; padding-top:20px"
				class="anniu">
				<div id="btn_div1" style="display: none">
					<button class="btn btn-danger radius my-btn" onclick="saveDecorationWall(0)"
						type="button">提交</button>
					<button class="btn btn-danger radius my-btn" onclick="saveDecorationWall(1)"
						type="button">保 存</button>
					<a class="btn btn-default radius"
						onClick="resetForm(this);"> 重置 </a> <br />
				</div>
				<div id="btn_div2" style="display:none;">
					<shiro:hasPermission name="permission:edit"> 
						<button id="modifyBtn" type="button"
							class="btn btn-danger radius my-btn" onclick="saveDecorationWall(3)">启用编辑</button>
						<button class="btn btn-danger radius my-btn hidbtn"
							onclick="saveDecorationWall(2)" type="button">保存修改</button>
						<a class="btn btn-default radius hidbtn"
							onClick="resetForm(this);">重置</a>
					</shiro:hasPermission> 	
				</div>
			</div>
			<!-- anniu end -->
			
		</div>
		<!-- main end  -->
		</form>
		<div style="padding: 5px" class="changeTable">
			<!-- 信用信息更改字段列表 -->
			<table id="decWallsChageTable" style="table-layout:fixed"></table>
		</div>
	</div>
	<!--contentt end  -->
	<script type="text/javascript">
		var wallId;//墙面id变量
		//var wallArray=new Array();//记录墙面待删除的附件id
		$(function() {
			//初始化表单提交事件
			mySubmit("CheckReceiveWallAddForm", saveCheckReceiveWall, CheckReceiveWallAddSuccess);
			//初始化上传插件
			initWebUpload("filePicker_m","list_m","装修验收四壁-门","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_mt","list_mt","装修验收四壁-门套","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_c","list_c","装修验收四壁-窗","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_ct","list_ct","装修验收四壁-窗套","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_hl","list_hl","装修验收四壁-护栏","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_dykz","list_dykz","装修验收四壁-电源控制","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_dycz","list_dycz","装修验收四壁-电源插座","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_wljk","list_wljk","装修验收四壁-网络接口","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_dhjk","list_dhjk","装修验收四壁-电话接口","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_dsjk","list_dsjk","装修验收四壁-电视接口","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_nqzp","list_nqzp","装修验收四壁-暖气组片","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_ktkd","list_ktkd","装修验收四壁-空调孔洞","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_ktwz","list_ktwz","装修验收四壁-空调位置","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_qmzsw","list_qmzsw","装修验收四壁-墙面装饰物","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_tl","list_tl","装修验收四壁-涂料","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_bz","list_bz","装修验收四壁-壁纸","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_rb","list_rb","装修验收四壁-软包","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_mb","list_mb","装修验收四壁-木包","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_bl","list_bl","装修验收四壁-玻璃","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_brickMaterial","list_brickMaterial","装修验收四壁-砖材","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_waterHeater","list_waterHeater","装修验收四壁-热水器","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			initWebUpload("filePicker_lampblackMachine","list_lampblackMachine","装修验收四壁-油烟机","CheckReceiveWallAdd_articleId",CheckReceiveWallSuccess,CheckReceiveWallErr);
			
			//当刚开始这个div没有被展示 display=none时 这个div的宽高会为0，导致不能点击，所以要手动设置高度
			$("div[id^=filePicker] div").css({"width":"60px","height":"30px"});
		//初始化表格,动态从服务器加载数据  
		 $("#decWallsChageTable").bootstrapTable({
				method : "post", //使用get请求到服务器获取数据  
				url : "customer/walls/getDecWallsChangeList", //获取数据的Servlet地址  
				striped : true, //表格显示条纹  
				pagination : true, //启动分页  
				pageSize : 2, //每页显示的记录数  
				pageNumber : 1, //当前第几页  
				pageList : [ 5, 10, 15, 20, 25 ], //记录数可选列表  
				sidePagination : "server", //表示服务端请求  
				contentType : 'application/x-www-form-urlencoded',
				//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder  
				//设置为limit可以获取limit, offset, search, sort, order  
				queryParamsType : "undefined",
				queryParams : function queryParams(params) { //设置查询参数  
					var param = {
						pageNumber : params.pageNumber,
						pageSize : params.pageSize,
						fkcustomerId : fkcustomerId,
						fkroomId : fkroomId
					};
					return param;
				},
				columns : [ {
					field : 'createtime',
					title : '修改时间',
					width : '15%',
					formatter:decWallsDataFormat
				}, {
					field : 'fieldname',
					title : '修改字段',
					width : '8%'
				}, {
					field : 'changebefore',
					title : '修改前数据',
					width : '25%',
					formatter:showText	
				}, {
					field : 'changeafter',
					title : '修改后数据',
					width : '25%',
					formatter:showText	
				}, {
					field : 'adduser',
					title : '修改人',
					width : '7%',
				}, {
					field : 'remarks',
					title : '变更说明',
					width : '20%',
					formatter:showText	
				} ]
			}); 
		});
		//日期格式化
		function decWallsDataFormat(value, row, index) {
			return new Date(row.createtime).format("yyyy-MM-dd hh:mm:ss");
		}
		//展示附件
		function getDecorationWallFiles(id) {
			getFileList(id, "装修验收四壁-门", "#list_m",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-门套", "#list_mt",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-窗", "#list_c",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-窗套", "#list_ct",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-护栏", "#list_hl",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-电源控制", "#list_dykz",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-电源插座", "#list_dycz",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-网络接口", "#list_wljk",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-电话接口", "#list_dhjk",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-电视接口", "#list_dsjk",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-暖气组片", "#list_nqzp",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-空调孔洞", "#list_ktkd",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-空调位置", "#list_ktwz",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-墙面装饰物", "#list_qmzsw",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-涂料", "#list_tl",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-壁纸", "#list_bz",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-软包", "#list_rb",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-木包", "#list_mb",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-玻璃", "#list_bl",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-砖材", "#list_brickMaterial",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-热水器", "#list_waterHeater",wallImgRemove, imgPlus);
			getFileList(id, "装修验收四壁-油烟机", "#list_lampblackMachine",wallImgRemove, imgPlus);
		}
		
		//更改按钮样式
		var optWall;
		//optWall操作字段，0：临时保存；1：新增；2：修改
		function saveDecorationWall(val) {
			optWall = val;
			if (val == 3) {
				if(approvalCountWall == 0){
					//解除锁定状态
					var index = layer.confirm('确定开启编辑状态？', {
						offset : '20%',
						shade : 0
					}, function() {
						$("#dw_div").show();
						//去除只读开启按钮编辑
						$("#CheckReceiveWallAddForm").find("input,textarea").attr("readonly", false);
						$("#CheckReceiveWallAddForm").find("select").attr("disabled", false);
						//禁止点击上传按钮
						$("#CheckReceiveWallAddForm div[id^='filePicker']").unbind("click").show();
						$("#CheckReceiveWallAddForm span.uploadcancel").show();
						$("#CheckReceiveWallAddForm #modifyBtn").hide();
						$("#CheckReceiveWallAddForm .hidbtn").addClass("showbtn"); 
						layer.close(index);
					});
				}else{
					layer.msg("此条数据已提交过审批，不能重复提交");
				}
			} else{
				$("#CheckReceiveWallAddForm").submit();
			}
		}
		//添加编辑页面数据  wall：该房屋类型下所有方向墙的集合
		function initCheckReceiveWallAddForm(wall){
			var s2 = $("#CheckReceiveWallAddForm select[name='direction']");
			var tem;//用来记录下拉第一项的值
			//过滤出所有方向集合 过滤之前先清空
			s2.children().remove();
			s2.append("<option value='' selected='selected'>请选择</option>");
			$.each(wall,function(i,v){
				if(i==0){
					tem=v.direction;
				}
				s2.append("<option value="+v.direction+">"+v.direction+"</option>");
			});
			//s2绑定change事件
			s2.unbind("change");
			s2.change(function(){
				directionOnChange(this,wall);
			});
			
			//初始化s2
			s2.select2({
				tags : true //可搜索
			});
			//设置默认值
			s2.val(tem).trigger("change");
			
		}
		//方位下拉change事件
		function directionOnChange(_this,wall){
			//进行赋值
			var vl = $(_this).val();
			//循环找出来该方位对应的数据
			var temp;
			$.each(wall,function(i,v){
				if(v.direction==vl){
					temp=v;
					//点击上传按钮打开
					$("#CheckReceiveWallAddForm div[id^='filePicker']").unbind("click").hide();
					$("#CheckReceiveWallAddForm span.uploadcancel").hide();
					return false;
				}else{
					//点击上传按钮打开
					$("#CheckReceiveWallAddForm div[id^='filePicker']").unbind("click").show();
					$("#CheckReceiveWallAddForm span.uploadcancel").show();
				}
			});
			setWallsValues(temp);
			
		}
		
		//重置表单为新增状态
		function wallsResetForm(){
			//先解除表单锁定
			$("#CheckReceiveWallAddForm").find("input,textarea").attr("readonly", false);
			//解除上传锁定
			$("#CheckReceiveWallAddForm div[id^='filePicker']").css("display","inline-block").unbind("click");
			$("#CheckReceiveWallAddForm #btn_div2").hide();
			$("#CheckReceiveWallAddForm #btn_div1").show();
			//清空表单数据
			$("#CheckReceiveWallAddForm input").val("");
			$("#CheckReceiveWallAddForm div[id^='list']").find("*").remove(); 
		}
		var approvalCountWall=0;
		//墙数据赋值	 data 某个房屋类型下某个方向墙的数据	
		function setWallsValues(wall){
			//赋值之前先重置表单
			wallsResetForm();
			approvalCountWall=0;
			
			//开始赋值
			if(wall){
				approvalCountWall = wall.approvalCount;
				wallId=wall.id;
				//获取附件
				getDecorationWallFiles(wallId);
				
				$("#CheckReceiveWallAddForm input[name='door']").val(wall.door);
				$("#CheckReceiveWallAddForm input[name='doorCase']").val(wall.doorCase);
				$("#CheckReceiveWallAddForm input[name='window']").val(wall.window);
				$("#CheckReceiveWallAddForm input[name='windowCase']").val(wall.windowCase);
				$("#CheckReceiveWallAddForm input[name='guardBar']").val(wall.guardBar);
				$("#CheckReceiveWallAddForm input[name='powerCtrl']").val(wall.powerCtrl);
				$("#CheckReceiveWallAddForm input[name='powerSocket']").val(wall.powerSocket);
				$("#CheckReceiveWallAddForm input[name='networkSocket']").val(wall.networkSocket);
				$("#CheckReceiveWallAddForm input[name='phoneSocket']").val(wall.phoneSocket);
				$("#CheckReceiveWallAddForm input[name='tvsocket']").val(wall.tvsocket);
				$("#CheckReceiveWallAddForm input[name='heating']").val(wall.heating);
				$("#CheckReceiveWallAddForm input[name='airconditionerHole']").val(wall.airconditionerHole);
				$("#CheckReceiveWallAddForm input[name='airconditionerSite']").val(wall.airconditionerSite);
				$("#CheckReceiveWallAddForm input[name='dope']").val(wall.dope);
				$("#CheckReceiveWallAddForm input[name='wallpaper']").val(wall.wallpaper);
				$("#CheckReceiveWallAddForm input[name='softRoll']").val(wall.softRoll);
				$("#CheckReceiveWallAddForm input[name='woodRoll']").val(wall.woodRoll);
				$("#CheckReceiveWallAddForm input[name='glass']").val(wall.glass);
				$("#CheckReceiveWallAddForm input[name='wallDecorate']").val(wall.wallDecorate);
				$("#CheckReceiveWallAddForm input[name='waterHeater']").val(wall.waterHeater);//热水器
				$("#CheckReceiveWallAddForm input[name='rangeHood']").val(wall.rangeHood);//油烟机
				$("#CheckReceiveWallAddForm input[name='wallBrick']").val(wall.wallBrick);//装饰下的砖材
				//隐藏按钮
				$("#CheckReceiveWallAddForm #btn_div2").show();
				$("#CheckReceiveWallAddForm #btn_div1").hide();
				$("#CheckReceiveWallAddForm").find("input,textarea").attr("readonly", true);
				$("#CheckReceiveWallAddForm").find("select").attr("disabled", true);
				$("#CheckReceiveWallAddForm").find("select[name='direction']").attr("disabled", false);
				$("#CheckReceiveWallAddForm .hidbtn").removeClass("showbtn");
				$("#CheckReceiveWallAddForm #modifyBtn").show();
				//锁定上传，同时隐藏按钮
				$("#CheckReceiveWallAddForm div[id^='filePicker']").unbind("click").click(function(){
						return false;
				}).hide(); 
			}else{
				$("#CheckReceiveWallAddForm #dw_div").hide();
			}
			//如果是历史状态，所有按钮都设置不能操作
		 	if(historyStatus==1){
				//隐藏按钮
				 $("#CheckReceiveWallAddForm #btn_div2").hide();
				$("#CheckReceiveWallAddForm #btn_div1").hide();
				$("#CheckReceiveWallAddForm").find("input,textarea").attr("readonly", true);
				$("#CheckReceiveWallAddForm").find("select").attr("disabled", true);
				$("#CheckReceiveWallAddForm").find("select[name='direction']").attr("disabled", false);
				//锁定上传，同时隐藏按钮
				$("#CheckReceiveWallAddForm div[id^='filePicker']").hide(); 
				$("#CheckReceiveWallAddForm #dw_div").hide();
			} 
		}
		
		function saveCheckReceiveWall(){
			var mli = layer.load(2);
			var roomType = $("#roomType").val();
			//房间号、客户id
			var fkcustomerId= parent.$("#customerId").val();
			var fkroomId = parent.$("#roomId").val();
			var direction=$("#CheckReceiveWallAddForm select[name='direction']").val();
			var door=$("#CheckReceiveWallAddForm input[name='door']").val();
			var doorCase=$("#CheckReceiveWallAddForm input[name='doorCase']").val();
			var window=$("#CheckReceiveWallAddForm input[name='window']").val();
			var windowCase=$("#CheckReceiveWallAddForm input[name='windowCase']").val();
			var guardBar=$("#CheckReceiveWallAddForm input[name='guardBar']").val();
			var powerCtrl=$("#CheckReceiveWallAddForm input[name='powerCtrl']").val();
			var powerSocket=$("#CheckReceiveWallAddForm input[name='powerSocket']").val();
			var networkSocket=$("#CheckReceiveWallAddForm input[name='networkSocket']").val();
			var phoneSocket=$("#CheckReceiveWallAddForm input[name='phoneSocket']").val();
			var tvsocket=$("#CheckReceiveWallAddForm input[name='tvsocket']").val();
			var heating=$("#CheckReceiveWallAddForm input[name='heating']").val();
			var airconditionerHole=$("#CheckReceiveWallAddForm input[name='airconditionerHole']").val();
			var airconditionerSite=$("#CheckReceiveWallAddForm input[name='airconditionerSite']").val();
			var dope=$("#CheckReceiveWallAddForm input[name='dope']").val();
			var wallpaper=$("#CheckReceiveWallAddForm input[name='wallpaper']").val();
			var softRoll=$("#CheckReceiveWallAddForm input[name='softRoll']").val();
			var woodRoll=$("#CheckReceiveWallAddForm input[name='woodRoll']").val();
			var glass=$("#CheckReceiveWallAddForm input[name='glass']").val();
			var wallDecorate=$("#CheckReceiveWallAddForm input[name='wallDecorate']").val();
			var AccessoryCaList=$("#CheckReceiveWallAdd_articleId").val();
			var waterHeater = $("#CheckReceiveWallAddForm input[name='waterHeater']").val();//热水器
			var rangeHood = $("#CheckReceiveWallAddForm input[name='rangeHood']").val();//油烟机
			var wallBrick = $("#CheckReceiveWallAddForm input[name='wallBrick']").val();//装饰下的砖材
			var remark = $("#dwRemark").val();
			if(optWall == "2"){
				if(remark == "" || remark == undefined){
					layer.msg("变更说明不能为空");
					layer.close(mli);
					return null;
				}
			}
			if(direction==""||direction==null){
				layer.close(mli);
				layer.alert("方位不能为空");
				return null;
			}
			
		    return {
		    	id:wallId,
		    	wailDelFile:wallArray,
		        fkcustomerId:fkcustomerId,
		    	fkroomId:fkroomId,
		    	roomType:roomType,
		    	direction:direction,
		    	door:door,
		    	doorCase:doorCase,
		    	window:window,
		    	windowCase:windowCase,
		    	guardBar:guardBar,
		    	powerCtrl:powerCtrl,
		    	powerSocket:powerSocket,
		    	networkSocket:networkSocket,
		    	phoneSocket:phoneSocket,
		    	tvsocket:tvsocket,
		    	heating:heating,
		    	airconditionerHole:airconditionerHole,
		    	airconditionerSite:airconditionerSite,
		    	dope:dope,
		    	wallpaper:wallpaper,
		    	softRoll:softRoll,
		    	woodRoll:woodRoll,
		    	glass:glass,
		    	wallDecorate:wallDecorate,
		    	waterHeater:waterHeater,
		    	rangeHood:rangeHood,
		    	wallBrick:wallBrick,
		    	AccessoryCaList:AccessoryCaList,
		    	opt:optWall,
		    	remark:remark
	        }
		}
		
		function CheckReceiveWallAddSuccess(responseText){
			layer.close(layer.index);
			if (responseText.success) {
				layer.alert("保存成功！", {
					offset:'20%',
					shade:[0.1,'#fff']
				}, function() {
					parent.tabToken=3;
					parent.houseType=$("#roomType").val();
					location.reload();
				});
			} else {
				layer.alert('保存失败！');
			}
		}
		
		//上传成功回调
	 	function CheckReceiveWallSuccess(file,response){
	 		successImg(file.id);
	 	}
	  	//上传失败回调
	  	function CheckReceiveWallErr(file,data){
	  		//alert("上传失败回调");
	  	}
	  	//图片删除按钮事件 wallArray
		function wallImgRemove(id,_this){
			layer.confirm('删除该图片？',{
				title:'警告',
				icon:0,
				shade:[0.1, '#fff']
			},function(){
				wallArray.push(id);
				//删除指定缩略图
				$("#"+id).remove();
				layer.close(layer.index);
			});
		}
	  	
	  	
	</script>
</body>
</html>